package com.xrit.sunnyday.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.xrit.sunnyday.dao.ReportMapper;
import com.xrit.sunnyday.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service(interfaceClass = ReportService.class)
public class ReportServiceImpl implements ReportService {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public Map<String, Object> findBusiness() {
        //1,我们需要返回map,所有new Map集合
        HashMap<String, Object> map = new HashMap<>();
        //2,调用方法
        //调用查询当天会员方法,并添加到map集合
        Integer memberDayCount = reportMapper.memberDayCount();
        map.put("todayNewMember",memberDayCount);
        //调用查询本周会员的方法,并添加到map集合
        Integer memberWeekCount = reportMapper.memberWeekCount();
        map.put("thisWeekNewMember",memberWeekCount);
        //调用查询本月会员的方法,并添加到map集合
        Integer memberMonthCount = reportMapper.memberMonthCount();
        map.put("thisMonthNewMember",memberMonthCount);
        //调用查询会员总数的方法,并添加到map集合
        Integer memberSum = reportMapper.memberSum();
        map.put("totalMember",memberSum);
        //调用查询今天预约人数的方法,并添加到map集合
        Integer todayOrderNumber = reportMapper.todayOrderNumber();
        map.put("todayOrderNumber",todayOrderNumber);
        //调用查询本周预约人数的方法,并添加到map集合
        Integer thisWeekOrderNumber = reportMapper.thisWeekOrderNumber();
        map.put("thisWeekOrderNumber",thisWeekOrderNumber);
        //调用查询本月预约人数的方法,并添加到map集合
        Integer thisMonthOrderNumber = reportMapper.thisMonthOrderNumber();
        map.put("thisMonthOrderNumber",thisMonthOrderNumber);
        String visits="已到诊";
        //调用查询今日到诊数的方法,并添加到map集合
        Integer todayVisitsNumber = reportMapper.todayVisitsNumber(visits);
        map.put("todayVisitsNumber",todayVisitsNumber);
        //调用查询本周到诊数的方法,并添加到map集合
        Integer thisWeekVisitsNumber = reportMapper.thisWeekVisitsNumber(visits);
        map.put("thisWeekVisitsNumber",thisWeekVisitsNumber);
        //调用查询本月到诊数的方法,并添加到map集合
        Integer thisMonthVisitsNumber = reportMapper.thisMonthVisitsNumber(visits);
        map.put("thisMonthVisitsNumber",thisMonthVisitsNumber);
        //调用查询热门套餐,套餐名称,各个套餐数量,套餐备注,套餐占比的方法,并添加到map集合
        List<Map<String, Object>> mapList = reportMapper.findhotSetmeal();
        map.put("hotSetmeal",mapList);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date reportDate=new Date();
        String formatDate = sdf.format(reportDate);
        map.put("reportDate",formatDate);
        //将map返回
        return map;
    }
}
